<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>人员创建</title>
    <link rel="stylesheet" href="${ctx}/static/css/datepicker.css" />
</head>

<body>

<div class="main-content-inner">
    <!-- #section:basics/content.breadcrumbs -->
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="ace-icon fa fa-home home-icon"></i>
                <a href="${ctx}/welcome">主页</a>
            </li>
            <li class="active">人员列表</li>
        </ul><!-- /.breadcrumb -->

    </div>
    <!-- /section:basics/content.breadcrumbs -->

    <div class="page-content">

        <c:if test="${not empty message}">
            <div id="message" class="alert alert-success">
                <button data-dismiss="alert" class="close">×</button>
                    ${message}</div>
        </c:if>

        <div class="page-header">
            <h1>
                人员
                <small>
                    <i class="ace-icon fa fa-angle-double-right"></i>
                    <c:choose>
                        <c:when test="${action eq 'create' }">
                            新增人员
                        </c:when>
                        <c:otherwise>
                            更新人员
                        </c:otherwise>
                    </c:choose>
                </small>
            </h1>
        </div><!-- /.page-header -->

        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="row">
                    <div class="col-xs-12">

                        <form id="inputForm" action="${ctx}/person/${action}" method="post" class="form-horizontal">
                            <input type="hidden" name="id" id="id" value="${person.id}"/>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 姓氏: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="familyName"
                                           name="familyName" value="${person.familyName}" placeholder="姓氏"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 名: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="name"
                                           name="name" value="${person.name}" placeholder="名"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 年龄: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="age"
                                           name="age" value="${person.age}" placeholder="年龄"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 性别: </label>
                                <div class="col-sm-9">
                                    <select class="chosen-select form-control" id="s" name="s" data-placeholder="">
                                        <option value="">请选择</option>
                                        <option value="M">男</option>
                                        <option value="F" selected="selected">女</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 是否在世: </label>
                                <div class="col-sm-9">
                                    <select class="chosen-select form-control" id="alive" name="alive" data-placeholder="">
                                        <option value="">请选择</option>
                                        <option value="0">在世</option>
                                        <option value="1" selected="selected">离世</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 是否已婚: </label>
                                <div class="col-sm-9">
                                    <select class="chosen-select form-control" id="marry" name="marry" data-placeholder="">
                                        <option value="">请选择</option>
                                            <option value="0">未婚</option>
                                            <option value="1" selected="selected">已婚</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 出生日期: </label>
                                <div class="col-sm-9">
                                    <input  id="borntimeStr"  name="borntimeStr"  class="datepicker col-xs-10 col-sm-5" value="<fmt:formatDate value="${person.bornTime}" pattern="yyyy-MM-dd" />" placeholder="出生日期" />
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 出生地址: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="bornAddress"
                                           name="bornAddress" value="${person.bornAddress}" placeholder="出生地址"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 世代: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="generation"
                                           name="generation" value="${person.generation}" placeholder="世代"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 排行: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="position"
                                           name="position" value="${person.position}" placeholder="排行"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 教育程度: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="education"
                                           name="education" value="${person.education}" placeholder="教育程度"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 公司名称: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="company"
                                           name="company" value="${person.company}" placeholder="公司名称"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 学校: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="school"
                                           name="school" value="${person.school}" placeholder="学校"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 用户Id: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="userId"
                                           name="userId" value="${person.user.id}" placeholder="用户Id"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                          <%--  <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 家族编号: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="familyId"
                                           name="familyId" value="${person.familyId}" placeholder="家族编号"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>--%>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 父亲编号: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="f"
                                           name="f" value="${person.f}" placeholder="父亲编号"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 母亲编号: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="m"
                                           name="m" value="${person.m}" placeholder="母亲编号"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 妻子编号: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="ux"
                                           name="ux" value="${person.ux}" placeholder="妻子编号"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 丈夫编号: </label>
                                <div class="col-sm-9">
                                    <input type="text" maxlength="15" autocomplete="off" id="vir"
                                           name="vir" value="${person.vir}" placeholder="丈夫编号"
                                           class="col-xs-10 col-sm-5 required"/>
                                </div>
                            </div>
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-3 col-md-9">
                                    <button id="submit_btn" class="btn btn-info" type="submit">
                                        <i class="ace-icon fa fa-check bigger-110"></i>
                                        提交
                                    </button>

                                    &nbsp; &nbsp; &nbsp;
                                    <button id="cancel_btn" class="btn" type="reset" onclick="history.back()">
                                        <i class="ace-icon fa fa-undo bigger-110"></i>
                                        返回
                                    </button>
                                </div>
                            </div>

                        </form>

                    </div><!-- /.span -->
                </div><!-- /.row -->
            </div>
        </div>

    </div><!-- /.page-content -->
</div>


<!-- inline scripts related to this page -->

<script src="${ctx}/static/js/jquery.validate.min.js"></script>
<script src="${ctx}/static/js/date-time/bootstrap-datepicker.js"></script>
<script src="${ctx}/static/js/messages_bs_zh.js"></script>

<script>
    $(document).ready(function () {

        $('#borntimeStr').datepicker({
            format: 'yyyy-mm-dd',
            maxViewMode: 1,
            minViewMode:1,
            weekStart: 1,
            autoclose: true,
            startView: 2,
            minView: 2,
            forceParse: false,
            language: 'zh-CN'
        });

        // 手机号码验证
        jQuery.validator.addMethod("isMobile", function (value, element) {
            var length = value.length;
            return this.optional(element) || (length == 11 && /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test(value));
        }, "请正确填写您的手机号码。");

        jQuery.validator.addMethod("checkcount", function (value, element) {
            var count = /^[a-zA-Z0-9]{1,}$/;    //电话号码格式010-12345678
            return this.optional(element) || (count.test(value));
        }, "账号只能输入字母和数字");

        //为inputForm注册validate函数
        <%--$("#inputForm").validate({--%>
            <%--onsubmit: true,--%>
            <%--rules: {--%>
                <%--idCard: {--%>
                    <%--maxlength: 18,--%>
                    <%--minlength: 18--%>
                <%--},--%>
                <%--name: {--%>
                    <%--rangelength: [2, 10]--%>
                <%--},--%>
                <%--mobile: {--%>
                    <%--rangelength: [11, 11],--%>
                    <%--isMobile: true,--%>
                    <%--remote: "${ctx}/user/checkadmintel?userId=" + $("#id").val()--%>
                <%--},--%>
                <%--loginName: {--%>
                    <%--checkcount: true,--%>
                    <%--rangelength: [4, 15],--%>
                    <%--remote: "${ctx}/user/checkLoginName?userId=" + $("#id").val()--%>
                <%--}--%>
            <%--},--%>
            <%--messages: {--%>
                <%--mobile: {--%>
                    <%--rangelength: "请输入11位手机号码",--%>
                    <%--isMobile: "请输入正确的手机号码",--%>
                    <%--remote: "手机号已存在"--%>
                <%--},--%>
                <%--loginName: {--%>
                    <%--rangelength: "请输入4-15位长度的数字或字符串",--%>
                    <%--remote: "用户账号已存在"--%>
                <%--}--%>
            <%--}--%>
        <%--});--%>

    });

    function alerta() {
        document.getElementById('inputForm').submit();
    }
</script>
</body>
</html>
